Model-view-controller (MVC) is an architectural pattern used in software engineering. Certain uses of this pattern may isolate business logic from user interface considerations, resulting in an application where it may be easier to modify either the visual appearance of the application or the underlying business rules without affecting the other.
Referring now to FIG. 1, in MVC, a model 10 represents the information (the data) of the application and the business rules used to manipulate the data, a view 12 corresponds to elements of the user interface such as text, checkbox items, and so forth, and a controller 14 manages details involving the communication to the model 10 of user actions such as keystrokes and mouse movements. As illustrated, method invocations appear in solid line and events appear in dashed line.
The model 10 may encapsulate the application state, respond to state queries, expose application functionality and notify the view 12 of changes. The view 12 may render the model 10, request updates from the model 10, send user gestures to the controller 14 and allow the controller 14 to select the view 10. The controller 14 may define application behavior, maps user actions to updates for the model 10 and select the view 12 for response.
Swing is a platform-independent, MVC graphical user interface (GUI) framework for Java. It follows a single-threaded programming model, and possesses the following traits: